package cn.xzhang.boot.mapper;

import cn.xzhang.boot.common.pojo.PageResult;
import cn.xzhang.boot.core.mapper.BaseMapperPlus;
import cn.xzhang.boot.model.dto.wallpaperDetails.WallpaperDetailsPageReqDTO;
import cn.xzhang.boot.model.entity.WallpaperDetails;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;

import java.util.Objects;

/**
 * @author XiaoZhangCode
 * @description 针对表【wallpaperDetails(壁纸表)】的数据库操作Mapper
 * @author <a href="https://github.com/XiaoZhangCode">XiaoZhangCode</a>
 */
public interface WallpaperDetailsMapper extends BaseMapperPlus<WallpaperDetails> {

    default PageResult<WallpaperDetails> selectPage(WallpaperDetailsPageReqDTO wallpaperDetailsPageReqDTO) {
        return selectPage(wallpaperDetailsPageReqDTO, new LambdaQueryWrapper<WallpaperDetails>()
                .eq(Objects.nonNull(wallpaperDetailsPageReqDTO.getNickname()), WallpaperDetails::getNickname, wallpaperDetailsPageReqDTO.getNickname())
                .eq(Objects.nonNull(wallpaperDetailsPageReqDTO.getDescription()), WallpaperDetails::getDescription, wallpaperDetailsPageReqDTO.getDescription())
                .eq(Objects.nonNull(wallpaperDetailsPageReqDTO.getSmallPicUrl()), WallpaperDetails::getSmallPicUrl, wallpaperDetailsPageReqDTO.getSmallPicUrl())
                .eq(Objects.nonNull(wallpaperDetailsPageReqDTO.getPicUrl()), WallpaperDetails::getPicUrl, wallpaperDetailsPageReqDTO.getPicUrl())
                .eq(Objects.nonNull(wallpaperDetailsPageReqDTO.getReviewMessage()), WallpaperDetails::getReviewMessage, wallpaperDetailsPageReqDTO.getReviewMessage())
                .orderByDesc(WallpaperDetails::getCreateTime)

        );
    }

}




